package com.guojian.sso.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.web.servlet.ShiroHttpServletRequest;

/**
 * 
 * 使用 @ShiroHttpSession 替换默认的session实现
 * 
 * @author guoJian
 *
 */
public class SessionFilter implements Filter {

	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		HttpServletRequest httpServletRequest = (HttpServletRequest) request;
		ShiroHttpServletRequest shiroRequest = new ShiroHttpServletRequest(httpServletRequest,
				httpServletRequest.getServletContext(), false);
		chain.doFilter(shiroRequest, response);
	}

	public static void main(String[] args) {

	}

}
